#include "view.h"
#include "math.h"

#include <QDebug>
#include <QVector>

#include "gun.h"

View::View(QWidget *parent) : QGraphicsView(parent){
    map = new Map(-250,-250,500,500);

    setScene(map);

    //player = new Player(300,-300);

    mouse = new Mouse();

    map->addItem(mouse);
    mouse->grabMouse();
    //map->addPlayer(player);

    //player->grabKeyboard();
   // player->setMouse(mouse);
    //player->setGun(new Gun(player));


    /*map->addObstacle(QVector<QPointF>() << QPointF(-200,-100) << QPointF(-100,-100) << QPointF(0,0) << QPointF(-100,0));
    map->addObstacle(QVector<QPointF>() << QPointF(10,10) << QPointF(100,100) << QPointF(0,200));
    map->addObstacle(QVector<QPointF>() << QPointF(-20,230) << QPointF(-200,230) << QPointF(-200,400) << QPointF(-20,400));
    map->addObstacle(QVector<QPointF>() << QPointF(-100,-100) << QPointF(400,-200) << QPointF(300,-0));*/

    /*timer = new QTimer(this);

    connect(timer, SIGNAL(timeout()), this, SLOT(timerTick()));
    timer->start(20);*/
}

void View::timerTick() {

    //map->updateMap();
}

void View::mouseMoveEvent(QMouseEvent* evt)
{
    mouse->setPos(mapToScene(evt->pos()));
}

void View::mousePressEvent(QMouseEvent* evt)
{
    mouse->mousePressEvent(evt);
}

void View::mouseReleaseEvent(QMouseEvent* evt)
{
    mouse->mouseReleaseEvent(evt);
}




